package com.example.broadcastreceiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

/**
 * author：sunweihao
 * 创建时间：2021/3/26 20:06
 * Describe：
 */
public class AppStateChangeReceiver extends BroadcastReceiver {
    private static final String TAG = "AppStateChangeReceiver";
    @Override
    public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();
        if (action.equals(Intent.ACTION_PACKAGE_ADDED)) {
            Log.d(TAG, "onReceive: 应用安装了，它的信息是"+intent.getData());
        }else if (action.equals(Intent.ACTION_PACKAGE_REMOVED)){
            Log.d(TAG, "onReceive: 应用卸载了"+intent.getData());
        }
    }
}
